<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('出入库流水列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="btn-group-sm" id="toolbar" role="group">
            <a id="save" class="btn btn-primary btn-rounded btn-sm"><i
            ></i>&nbsp;保存数据</a>
        </div>
        <div id="div" style="height: 100%;text-align: center" class="col-sm-12 select-table striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('search:IssueReceiptFlow:edit')}]];
    var removeFlag = [[${@permission.hasPermi('search:IssueReceiptFlow:remove')}]];
    var prefix = ctx + "db/RGVdb";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            // clickToSelect: true,//是否启用点击选中行
            height: $("#div").height() / 1,
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "RGV测试",
            columns: [
                // {
                //     checkbox: true,
                //
                // },
                {
                    field: 'czfs',
                    title: '操作方式',
                    visible: true
                },
                {
                    field: 'sbzt',
                    title: '设备状态',
                    sortable: true
                },
                {
                    field: 'zhzt',
                    title: '载货状态',
                    sortable: true
                },
                {
                    field: 'rwcx',
                    title: '#',
                    sortable: true
                },
                {
                    field: 'qqcf',
                    title: '请求重分',
                    sortable: true
                },
                {
                    field: 'yxxf',
                    title: '允许下发',
                    sortable: true
                },
                {
                    field: 'zxrwh',
                    title: '执行任务号',
                    visible: true
                },
                {
                    field: 'rwlx',
                    title: '任务类型',
                    visible: true
                },
                {
                    field: 'zlgs',
                    title: '指令格式',
                    visible: true
                },
                {
                    field: 'zxjd',
                    title: '执行阶段',
                    visible: true
                },
                {
                    field: 'yxzt',
                    title: '运行状态',
                    visible: true
                },
                {
                    field: 'dqwz',
                    title: '当前位置',
                    visible: true
                },
                {
                    field: 'mbwz',
                    title: '目标位置',
                    visible: true
                },
                {
                    field: 'yxsd',
                    title: '运行速度',
                    visible: true
                },
                {
                    field: 'yczt',
                    title: '异常状态',
                    visible: true
                },
                {
                    field: 'dql_lift',
                    title: '当前列左',
                    visible: true
                },
                {
                    field: 'dql_right',
                    title: '当前列右',
                    visible: true
                },
                {
                    field: 'yxmbp',
                    title: '目标排',
                    visible: true
                },
                {
                    field: 'yxmbl',
                    title: '目标列',
                    visible: true
                },
            ],
            onClickCell: function (field, value, row, $element) {
                $element.attr('contenteditable', true);
                $element.blur(function () {
                    let tdValue = $element.html();
                    tdValue=tdValue.replace(/<br>/g, "")
                    switch (field) {
                        case "czfs":
                            row.czfs = tdValue;
                            break;
                        case "sbzt":
                            row.sbzt = tdValue;
                            break;
                        case "zhzt":
                            row.zhzt = tdValue;
                            break;
                        case "rwcx":
                            row.rwcx = tdValue;
                            break;
                        case "qqcf":
                            row.qqcf = tdValue;
                            break;
                        case "yxxf":
                            row.yxxf = tdValue;
                            break;
                        case "zxrwh":
                            row.zxrwh = tdValue;
                            break;
                        case "rwlx":
                            row.rwlx = tdValue;
                            break;
                        case "zlgs":
                            row.zlgs = tdValue;
                            break;
                        case "zxjd":
                            row.zxjd = tdValue;
                            break;
                        case "yxzt":
                            row.yxzt = tdValue;
                            break;
                        case "dqwz":
                            row.dqwz = tdValue;
                            break;
                        case "mbwz":
                            row.mbwz = tdValue;
                            break;
                        case "yxsd":
                            row.yxsd = tdValue;
                            break;
                        case "yczt":
                            row.yczt = tdValue;
                            break;
                        case "dql_lift":
                            row.yxzt = tdValue;
                            break;
                        case "dql_right":
                            row.yxzt = tdValue;
                            break;
                        case "yxmbp":
                            row.yxzt = tdValue;
                            break;
                        case "yxmbl":
                            row.yxzt = tdValue;
                            break;
                    }
                })
            }
        };
        $.table.init(options);
    });

    $("#save").click(function () {
        var data = $("#bootstrap-table").bootstrapTable('getData');

        for (let i = 0; i < data.length; i++) {
            var shuju = "Ddjdb/edit?CZFS=" + data[i].czfs + "&CZFS=SBZT" + data[i].sbzt + "&ZHZT=" + data[i].zhzt+ "&RWCX=" +
                data[i].rwcx + "&QQCF=" + data[i].qqcf + "&YXXF=" + data[i].yxxf + "&ZXRWH=" + data[i].zxrwh + "&RWLX=" +
                data[i].rwlx + "&ZLGS=" + data[i].zlgs + "&ZXJD=" + data[i].zxjd + "&YXZT=" + data[i].yxzt + "&DQWZ=" +
                data[i].dqwz + "&MBWZ=" + data[i].mbwz + "&YXSD=" + data[i].yxsd + "&YCZT=" + data[i].yczt + "&DQL_LIFT=" +
                data[i].dql_lift + "&DQL_RIGHT=" + data[i].dql_right + "&YXMBP=" + data[i].yxmbp + "&YXMBL=" + data[i].yxmbl
            console.log(shuju)
            $.ajax({
                url: shuju,       //后台地址
                contentType: 'application/json',
                type: 'post',
                // data: JSON.stringify(info),
                dataType: 'json',
                success: function callbackss(data) {
                    location.reload()

                }
            })
        }
    })
</script>
</body>
</html>